package dut.ir.lxb.weibo.main;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import dut.ir.lxb.weibo.spider.LoginUser;
import dut.ir.lxb.weibo.spider.WeiboDownloader;

public class FamousPersonTest
{
	
	public static void main(String [] args)
	{
		
		WeiboDownloader downloader = new WeiboDownloader();
		LoginUser loginUser = new LoginUser("dutir11@sina.com", "lianxubao");
		downloader.setLoginUser(loginUser);
		downloader.init();
		
		//商界名人
		List<String> uids = downloader.downloadFamousPersonUid("http://d.weibo.com/1087030002_892_1001_0?page=%d#Pl_Core_F4RightUserList__4");
		writeUids(uids, "./config/商界名人.txt");
		//体育明星
		uids = downloader.downloadFamousPersonUid("http://d.weibo.com/1087030002_892_1002_0?page=%d#Pl_Core_F4RightUserList__4");
		writeUids(uids, "./config/体育明星.txt");
		//娱乐明星
		uids = downloader.downloadFamousPersonUid("http://d.weibo.com/1087030002_892_1003_0?page=%d#Pl_Core_F4RightUserList__4");
		writeUids(uids, "./config/娱乐明星.txt");
		//政府官员
		uids = downloader.downloadFamousPersonUid("http://d.weibo.com/1087030002_892_1004_0?page=%d#Pl_Core_F4RightUserList__4");
		writeUids(uids, "./config/政府官员.txt");
		//知名作家
		uids = downloader.downloadFamousPersonUid("http://d.weibo.com/1087030002_892_1005_0?page=%d#Pl_Core_F4RightUserList__4");
		writeUids(uids, "./config/知名作家.txt");
		//传媒精英
		uids = downloader.downloadFamousPersonUid("http://d.weibo.com/1087030002_892_1007_0?page=%d#Pl_Core_F4RightUserList__4");
		writeUids(uids, "./config/传媒精英.txt");
		
	}
	
	
	public static void writeUids(List<String> uids, String file)
	{
		try 
		{
			BufferedWriter br = new BufferedWriter(new FileWriter(file));
			for(String uid : uids)
			{
				br.write(uid);
				br.flush();
				br.newLine();
			}
			br.close();
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	
	
	
	
}
